import 'package:XinXiZiXun/common/utils/utils.dart';
import 'package:XinXiZiXun/common/values/values.dart';
import 'package:XinXiZiXun/gen_a/A.dart';
import 'package:flutter/material.dart';

class SystemSettingPage extends StatelessWidget {
  List prevArry = [
    ['重置密码'],
    ['隐私政策', '用户协议', '关于我们'],
    ['清除缓存']
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        backgroundColor: AppColors.primaryWhiteColor,
        leading: FlatButton(
          onPressed: () {
            Navigator.of(context).pop();
          },
          child: Image.asset(A.assets_images_ic_qihuo_back_white),
        ),
        title: Text(
          '系统设置',
          style: TextStyle(
            fontSize: duSetScaleFontSize(36.0),
            fontFamily: 'Montserrat',
            fontWeight: FontWeight.w500,
            color: AppColors.primaryBlackColor,
          ),
        ),
      ),
      body: ListView(
          children: prevArry
              .map((e) => renderElementOperation(
                  e,
                  EdgeInsets.only(
                    left: duSetWidth(ktDefaultPadding),
                    right: duSetWidth(ktDefaultPadding),
                    top: duSetWidth(ktDefaultPadding),
                  )))
              .toList()),
    );
  }

  ///渲染元素
  Widget renderElementOperation(List arry, EdgeInsets insets) {
    return Padding(
      padding: insets,
      child: Container(
        width: double.infinity,
        height: arry.length * duSetHeight(knDefaultPadding),
        decoration: BoxDecoration(
          color: AppColors.primaryWhiteColor,
          borderRadius: Radii.k8pxRadius,
        ),
        child: Column(
          children: arry.map((e) => renderSubElement(e)).toList(),
        ),
      ),
    );
  }

  ///渲染子元素
  Widget renderSubElement(String text) {
    return GestureDetector(
      onTap: () {
        print('render');
      },
      child: Container(
        height: duSetHeight(knDefaultPadding),
        child: Row(
          children: [
            SizedBox(
              width: duSetWidth(ktDefaultPadding),
            ),
            Text(
              text,
              style: TextStyle(
                fontSize: duSetScaleFontSize(28.0),
                fontFamily: 'Avenir',
                fontWeight: FontWeight.w400,
                color: AppColors.primaryDarkGrayColor,
              ),
            ),
            Spacer(),
            Image.asset(A.assets_images_ic_shezhi_jiantou),
            SizedBox(
              width: duSetWidth(ktDefaultPadding),
            ),
          ],
        ),
      ),
    );
  }
}
